package com.house365.core.view.special;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;

/**
 * 
 * @author py
 * @date 2012-12-21
 * @comment 屏蔽上层事件
 */
public class DuplicateParentStateAwareLinearLayout  extends LinearLayout {

    

    public DuplicateParentStateAwareLinearLayout(Context context,
			AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	public DuplicateParentStateAwareLinearLayout(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}
	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {
		return false;
	}
	/*
     * By default ViewGroup call setPressed on each child view, this take into account duplicateparentstate parameter
     */
     @Override
     protected void  dispatchSetPressed(boolean pressed) {
          for (int i = 0; i < getChildCount(); i++) {
             View child = getChildAt(i);
             if (child.isDuplicateParentStateEnabled()){
                 getChildAt(i).setPressed(pressed);
             }
         }
      }
}
